#pragma once
#define _CRT_SECURE_NO_WARNINGS
#include "HushTable.hpp"

class LZ77 {
public:

	LZ77();
	~LZ77();

	void CompressFile(const string& fileName, string outName = "");
	void DeCompressFile(const string& fileName, string outName = "");
	void WriteFlagInfo(FILE* fFlag, ushort matchLen, ushort matchDist, uchar& bitsInfo, uchar& bitsCnt);
private:

	ushort LongestMatch(ushort matchHead, ushort& matchDist, ushort start);
	void FillWindow(FILE* fIn, ull& lookahead, ushort& start);

private:
	uchar* _pWin;
	HashTable _ht;

	const static ushort MIN_LOOKAHEAD = MIN_MATCH + MAX_MATCH + 1;
	const static ushort MAX_DIST = WSIZE - MIN_LOOKAHEAD;
};